﻿/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A
 * copy of the license can be found at http://go.microsoft.com/fwlink/?LinkID=131993. If
 * you cannot locate the Microsoft Public License, please send an email to
 * mixon@microsoft.com. By using this source code in any fashion, you are agreeing to
 * be bound by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 *
 * ***************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace MIXOnline.Descry
{
    public static class Extender
    {
        /// <summary>
        /// Attempts to find a child in a UIElementCollection by name. If no child is found returns null.
        /// </summary>
        /// <param name="children"></param>
        /// <param name="childName"></param>
        /// <returns></returns>
        public static FrameworkElement E_FindChild(this UIElementCollection children, string childName)
        {
            foreach (FrameworkElement fe in children)
            {
                if (fe.Name == childName)
                    return fe;
            }
            return null;
        }
    }

    
}
